home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1985 November / Ahoy_Magazine_85-11_1985_Double_L.d64 / weighted keyboar (.txt) < prev   
Commodore BASIC  |  2022-10-26  |  836b  |  32 lines

  1. 0 print"[147]":poke53280,0:poke53281,6:poke646,1
  2. 1 rem
  3. 2 rem rupert report #23:monkey business
  4. 3 rem    >> weighted keyboard <<
  5. 4 rem
  6. 5 print"simulate a monkey at a special"
  7. 6 print"keyboard with numbers of keys"
  8. 7 print"in proportion to the frequency of"
  9. 8 print"each letter's usage in english."
  10. 9 rem
  11. 100 data 275," ",130,e,92,t,79,n
  12. 101 data 76,r,75,o,74,a,74,i,61,s
  13. 102 data 42,d,36,l,34,h,31,c,28,f
  14. 103 data 27,p,26,u,25,m,19,y,16,g
  15. 104 data 16,w,15,v,10,b,5,x,3,q
  16. 105 data 3,k,2,j,1,z,-1,*
  17. 185 rem -- pack strings with letters --
  18. 190 print chr$(147) "total = 0"
  19. 200 ct=0 : ix=0 : ttl=0
  20. 210 read n,c$ :nct=0 :if n=-1 then 300
  21. 220 a$(ix)=a$(ix)+c$
  22. 230 nct=nct+1 : ct=ct+1 : ttl=ttl+1
  23. 240 if ct=255 then ct=0 : ix=ix+1
  24. 250 if nct<n then 220
  25. 260 print chr$(19)tab(7) ttl : goto 210
  26. 295 rem   -- pick and print letters --
  27. 300 k=int(rnd(0)*ttl)
  28. 310 x=int(k/255) : ch=k-x*255+1
  29. 320 l$=mid$(a$(x),ch,1)
  30. 330 print l$;
  31. 340 goto 300
  32.